<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>html5 | 李世龙</title><meta name="keywords" content="html"><meta name="author" content="lee"><meta name="copyright" content="lee"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="HTML的基础语法以及新特性">
<meta property="og:type" content="article">
<meta property="og:title" content="html5">
<meta property="og:url" content="http://blog.cai2.wang/2021/11/16/Done/Html5/index.html">
<meta property="og:site_name" content="李世龙">
<meta property="og:description" content="HTML的基础语法以及新特性">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/undraw_good_team_m7uu.png">
<meta property="article:published_time" content="2021-11-16T14:09:47.000Z">
<meta property="article:modified_time" content="2022-08-23T11:25:02.206Z">
<meta property="article:author" content="lee">
<meta property="article:tag" content="html">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/undraw_good_team_m7uu.png"><link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/avatar.jpg"><link rel="canonical" href="http://blog.cai2.wang/2021/11/16/Done/Html5/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"简"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"bottom-left"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: true,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'html5',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-08-23 19:25:02'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const fontSizeVal = saveToLocal.get('global-font-size')
    if (fontSizeVal !== undefined) {
      document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
    }
    })(window)</script><link rel="stylesheet" href="/css/iconfont.css"><link rel="stylesheet" href="/css/index.min.css"><link rel="stylesheet" href="/css/bg.css"><meta name="generator" content="Hexo 5.4.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/avatar.jpg" onerror="onerror=null;src='https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">13</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">9</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/video/"><i class="fa-fw fas fa-video"></i><span> 视频</span></a></li><li><a class="site-page child" href="/love/"><i class="fa-fw fa fa-heartbeat"></i><span> 心动</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/my/"><i class="fa-fw fas fa-ad"></i><span> 我的</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-seedling"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">李世龙</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/video/"><i class="fa-fw fas fa-video"></i><span> 视频</span></a></li><li><a class="site-page child" href="/love/"><i class="fa-fw fa fa-heartbeat"></i><span> 心动</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/my/"><i class="fa-fw fas fa-ad"></i><span> 我的</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-seedling"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">html5</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-11-16T14:09:47.000Z" title="发表于 2021-11-16 22:09:47">2021-11-16</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-08-23T11:25:02.206Z" title="更新于 2022-08-23 19:25:02">2022-08-23</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/html/">html</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">10.2k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>43分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="html5"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div><article class="post-content" id="article-container"><h1 id="1-HTML"><a href="#1-HTML" class="headerlink" title="1, HTML"></a>1, HTML</h1><h2 id="1-1-什么是-HTML"><a href="#1-1-什么是-HTML" class="headerlink" title="1,1 什么是 HTML"></a>1,1 什么是 HTML</h2><p><strong>HTML</strong> 是指 <strong>超文本标记语言 (Hyper Text Markup language)</strong> , 是一种用于描述网页的语言</p>
<p><strong>HTML</strong> 不是编程语言 , 是一种标记语言 (==一套标记==)</p>
<p>例如 :</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;&quot;</span> <span class="attr">title</span>=<span class="string">&quot;&quot;</span> <span class="attr">alt</span>=<span class="string">&quot;&quot;</span> /&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>超文本 , 有两层含义:</strong></p>
<ul>
<li>它可以加入图片 , 声音 , 视频 , 动画 , 多媒体等内容 ( 超越文本所能描述的限制 )</li>
<li>它可以从一个网页文件跳转到另一个网页文件 , 与世界各地的主机文件进行链接 (超链接文本)</li>
</ul>
<h1 id="2-常用的浏览器"><a href="#2-常用的浏览器" class="headerlink" title="2, 常用的浏览器"></a>2, 常用的浏览器</h1><ul>
<li>IE : 不推荐使用 , 慢 , 解析网页的能力太差</li>
<li>FireFox : 火狐 , 推荐使用</li>
<li>Chrome : 谷歌 , 推荐使用</li>
<li>Safari : 苹果系统</li>
<li>Edge : 微软新推出的 , 不推荐</li>
</ul>
<h1 id="3-Web标准"><a href="#3-Web标准" class="headerlink" title="3, Web标准"></a>3, Web标准</h1><p>Web 标准是由 W3C 组织 和 其他标准化组织指定的 <strong>一系列标准集合</strong> , W3C (万维网联盟)</p>
<h2 id="3-1-为什么需要-Web-标准"><a href="#3-1-为什么需要-Web-标准" class="headerlink" title="3,1 为什么需要 Web 标准"></a>3,1 为什么需要 Web 标准</h2><p>浏览器的不同 , 他们显示的页面和排班就不同</p>
<p>不同浏览器解析的效果不一样 , 开发人员需要为每个浏览器做一个版本的网页 , 为了保证一个网页可以在不同的浏览器中国年显示的效果是一样的</p>
<h2 id="3-2-Web-标准的构成"><a href="#3-2-Web-标准的构成" class="headerlink" title="3,2 Web 标准的构成"></a>3,2 Web 标准的构成</h2><p>包括 : <strong>结构(Structure) , 表现 (Presentation) , 行为(Behivaor)</strong></p>
<table>
<thead>
<tr>
<th>标准</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>结构 ( HTML )</td>
<td>结构用于 <strong>网页元素</strong> 进行整理和分类</td>
</tr>
<tr>
<td>表现 ( CSS )</td>
<td>表现网页的版式 , 颜色 , 大小 , <strong>外观样式</strong></td>
</tr>
<tr>
<td>行为 ( JS )</td>
<td>网页和用户的交互的行为</td>
</tr>
</tbody></table>
<p><img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source_posts\01-HTML.assets\image-20211012160155298.png" alt="image-20211012160155298"></p>
<p>**简单理解 : **结构代码写在 HTML 文件中 , 样式的代码写在 CSS 文件中 , 有关于行为写在 JS 文件中</p>
<h1 id="4-HTML标签"><a href="#4-HTML标签" class="headerlink" title="4, HTML标签"></a>4, HTML标签</h1><ul>
<li>明确 HTML 的书写规范</li>
<li>掌握HTML的标签的骨架</li>
<li>写出超链接标签 , 图片标签</li>
<li>明确标签的各个属性的功能</li>
</ul>
<h1 id="5-HTML语法规范"><a href="#5-HTML语法规范" class="headerlink" title="5, HTML语法规范"></a>5, HTML语法规范</h1><h2 id="5-1-基本语法规范"><a href="#5-1-基本语法规范" class="headerlink" title="5,1 基本语法规范"></a>5,1 基本语法规范</h2><ol>
<li>HTML 标签是由尖括号组成的关键字 : <strong>&lt;html&gt;</strong></li>
<li>HTML 标签通常成对出现 , 例如 : <strong>&lt;html&gt;</strong> 和 <strong>&lt;/html&gt;</strong> , 这种标签我们称之为双标签 , 标签中的第一个是开始标签 , 第二个是结束标签 (闭合标签)</li>
<li>有些少量的标签是单个出现的 , 比如 : <strong>&lt;img /&gt;, &lt;br /&gt; ……</strong></li>
</ol>
<h2 id="5-2-标签的关系"><a href="#5-2-标签的关系" class="headerlink" title="5,2 标签的关系"></a>5,2 标签的关系</h2><p>标签的关系可以分为两种 : <strong>并列关系</strong> , <strong>包含(嵌套)关系</strong></p>
<p><strong>包含关系/父子关系/嵌套</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!--</span></span><br><span class="line"><span class="comment">	在HTML标签中包含这head表情啊,html为父级标签,head就是子级标签</span></span><br><span class="line"><span class="comment">--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">head</span>&gt;</span><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">body</span>&gt;</span><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>并列关系</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h1 id="6-HTML基本结构"><a href="#6-HTML基本结构" class="headerlink" title="6, HTML基本结构"></a>6, HTML基本结构</h1><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">        标题网页的元数据,标题,编码....</span><br><span class="line">        <span class="tag">&lt;<span class="name">title</span>&gt;</span>网页的标题<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    	网页中所有可视的内容</span><br><span class="line">    <span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>

<table>
<thead>
<tr>
<th>标签名</th>
<th>定义</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>&lt;html&gt;&lt;/html&gt;</td>
<td>HTML标签</td>
<td>页面中最大的标签 , 称之为 <strong>根标签</strong></td>
</tr>
<tr>
<td>&lt;head&gt;&lt;/head&gt;</td>
<td>文档的头部</td>
<td>注意在 head 标签中我们要设置编码格式,网页的标题</td>
</tr>
<tr>
<td>&lt;title&gt;&lt;/title&gt;</td>
<td>文档的标题</td>
<td>让网页拥有一个属于自己的标题</td>
</tr>
<tr>
<td>&lt;body&gt;&lt;/body&gt;</td>
<td>文档的主体</td>
<td>元素中包含了网页中的所有内容</td>
</tr>
</tbody></table>
<h1 id="7-HTML的常用标签"><a href="#7-HTML的常用标签" class="headerlink" title="7, HTML的常用标签"></a>7, HTML的常用标签</h1><h2 id="7-1-标题标签"><a href="#7-1-标题标签" class="headerlink" title="7,1 标题标签"></a>7,1 标题标签</h2><p>标题标签 : <strong>h1 ~ h6</strong></p>
<p>HTML 为我们提供了 6 个等级的标题标签</p>
<p><strong>特点 :</strong></p>
<ol>
<li>文字加粗 , 字体变大 </li>
<li>一个标题独占一行</li>
<li>等级越高字体越大 , 等级越小字体越小 , h1最大 , h6最小</li>
</ol>
<blockquote>
<p>代码</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 标题标签 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">h1</span>&gt;</span>我是1级标题标签<span class="tag">&lt;/<span class="name">h1</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">h2</span>&gt;</span>我是2级标题标签<span class="tag">&lt;/<span class="name">h2</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>我是3级标题标签<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">h4</span>&gt;</span>我是4级标题标签<span class="tag">&lt;/<span class="name">h4</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">h5</span>&gt;</span>我是5级标题标签<span class="tag">&lt;/<span class="name">h5</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">h6</span>&gt;</span>我是6级标题标签<span class="tag">&lt;/<span class="name">h6</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211012162918457.png" alt="image-20211012162918457" style="zoom:50%;border: solid" />    



<h2 id="7-2-段落和换行"><a href="#7-2-段落和换行" class="headerlink" title="7,2 段落和换行"></a>7,2 段落和换行</h2><ul>
<li><p><strong>段落标签 : &lt;p&gt; &lt;/p&gt;</strong></p>
<p>作用 : 用于将文档分割为多个段落</p>
<p><strong>特点 :</strong></p>
<ul>
<li>文档会根据浏览器窗口大小自动换行</li>
<li>段落和段落之间有默认的外边距 , 大小16px(Chrome)</li>
</ul>
</li>
<li><p><strong>换行标签 : &lt;br /&gt;</strong></p>
<p>作用 : 强制文本内容换行显示</p>
<p>**特点 : **</p>
<ul>
<li>单标签</li>
<li>只是简单的开启一行 , 跟段落不同 , 没有间距的</li>
</ul>
</li>
</ul>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 段落换行标签 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">p</span>&gt;</span>我是p标签 , </span><br><span class="line">    <span class="tag">&lt;<span class="name">br</span> /&gt;</span></span><br><span class="line">    是一行段落<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">p</span>&gt;</span>我是p标签 , 是一行段落<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">p</span>&gt;</span>我是p标签 , 是一行段落<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">p</span>&gt;</span>我是p标签 , 是一行段落<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211012163542182.png" alt="image-20211012163542182" style="zoom:50%;border: solid" />    



<h2 id="7-3-文本格式化标签"><a href="#7-3-文本格式化标签" class="headerlink" title="7,3 文本格式化标签"></a>7,3 文本格式化标签</h2><ul>
<li><p>**加粗 **</p>
<ul>
<li><strong>&lt;b&gt;&lt;/b&gt;</strong></li>
<li><strong>&lt;strong&gt;&lt;/strong&gt;</strong></li>
</ul>
<p>推荐是用 strong 标签 , 识别度高 , 语义强烈</p>
</li>
<li><p><strong>斜体</strong></p>
<ul>
<li><strong>&lt;i&gt;&lt;/i&gt;</strong></li>
<li><strong>&lt;em&gt;&lt;/em&gt;</strong></li>
</ul>
<p>推荐是用 em 标签 , 识别度高 , 语义强烈</p>
</li>
<li><p><strong>下划线</strong></p>
<ul>
<li><strong>&lt;u&gt;&lt;/u&gt;</strong></li>
<li><strong>&lt;ins&gt;&lt;/ins&gt;</strong></li>
</ul>
<p>推荐是用 ins 标签 , 识别度高 , 语义强烈</p>
</li>
<li><p><strong>删除线</strong></p>
<ul>
<li><strong>&lt;s&gt;&lt;/s&gt;</strong></li>
<li><strong>&lt;del&gt;&lt;/del&gt;</strong></li>
</ul>
<p>推荐是用 del 标签 , 识别度高 , 语义强烈</p>
</li>
</ul>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">strong</span>&gt;</span>我是strong标签,文字加粗<span class="tag">&lt;/<span class="name">strong</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">b</span>&gt;</span>我是b标签,文字加粗<span class="tag">&lt;/<span class="name">b</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">br</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">i</span>&gt;</span>我是i标签,文字斜体<span class="tag">&lt;/<span class="name">i</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">em</span>&gt;</span>我是em标签,文字斜体<span class="tag">&lt;/<span class="name">em</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">br</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">s</span>&gt;</span>我是s标签,文字加删除线<span class="tag">&lt;/<span class="name">s</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">del</span>&gt;</span>我是del标签,文字添加删除线<span class="tag">&lt;/<span class="name">del</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">br</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">u</span>&gt;</span>我是u标签,文字加下划线<span class="tag">&lt;/<span class="name">u</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">ins</span>&gt;</span>我是ins标签,文字加下划线<span class="tag">&lt;/<span class="name">ins</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211012165759261.png" alt="image-20211012165759261" style="zoom:50%;border: solid" />    



<ul>
<li><strong>上标和下标</strong><ul>
<li><strong>sup : 上标</strong></li>
<li><strong>sub : 下标</strong></li>
</ul>
</li>
</ul>
<p>作用 : 在某些数学的公式或者化学的符号会被大量的使用</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>文字的上标和下标<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">    2平方米: 2m<span class="tag">&lt;<span class="name">sup</span>&gt;</span>2<span class="tag">&lt;/<span class="name">sup</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">    水元素: H<span class="tag">&lt;<span class="name">sub</span>&gt;</span>2<span class="tag">&lt;/<span class="name">sub</span>&gt;</span>O</span><br><span class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013140107408.png" alt="image-20211013140107408" style="zoom:50%;border: solid" />    



<h2 id="7-4-lt-div-gt-和-lt-span-gt"><a href="#7-4-lt-div-gt-和-lt-span-gt" class="headerlink" title="7,4 &lt;div&gt; 和 &lt;span&gt;"></a>7,4 &lt;div&gt; 和 &lt;span&gt;</h2><p>这两个标签是没有具体语义 , 就是一个容器 , 盒子</p>
<p>作用 : 用于装在网页中的元素 , 并且起到网页布局的作用</p>
<p><strong>特点 :</strong> </p>
<ul>
<li>双标签</li>
<li>div 标签会换行 , 独占一行 , 大盒子</li>
<li>span 标签不会换行 , 一行中存在多个 , 小盒子</li>
</ul>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span>我是div<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span>我是div<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span>我是div<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">span</span>&gt;</span>我是span<span class="tag">&lt;/<span class="name">span</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">span</span>&gt;</span>我是span<span class="tag">&lt;/<span class="name">span</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211012170350856.png" alt="image-20211012170350856" style="zoom:50%;border: solid" />    



<h2 id="7-5-图像标签和路径"><a href="#7-5-图像标签和路径" class="headerlink" title="7,5 图像标签和路径"></a>7,5 图像标签和路径</h2><ul>
<li><strong>图像标签 : &lt;img /&gt;</strong></li>
<li><strong>图片标签的属性</strong><ul>
<li>**src : **图片资源的路径 , 必有属性 , 建议将图片资源放在 img 文件夹中 , img 文件包要和 .html 文件在统一的项目中</li>
<li>**alt : **替换图片 , 当图片显示失败的时候 , 显示的提示信息</li>
<li><strong>title :</strong> 鼠标经过图片时的提示信息</li>
<li><strong>width :</strong> 设置图片宽度 , 单位像素 px , 单位可以不写</li>
<li><strong>height :</strong> 设置图片高度 , 单位像素 px , 单位可以不写</li>
<li><strong>border :</strong> 设置图片的边框 , 单位像素 px</li>
</ul>
</li>
</ul>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h1</span>&gt;</span>图片标签<span class="tag">&lt;/<span class="name">h1</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;img/img01.jpg&quot;</span> <span class="attr">title</span>=<span class="string">&quot;汤米-谢尔比&quot;</span> <span class="attr">width</span>=<span class="string">&quot;300px&quot;</span> <span class="attr">height</span>=<span class="string">&quot;180px&quot;</span> </span></span><br><span class="line"><span class="tag">     <span class="attr">border</span>=<span class="string">&quot;5px&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;img/img01.jp&quot;</span> <span class="attr">title</span>=<span class="string">&quot;汤米-谢尔比&quot;</span> <span class="attr">width</span>=<span class="string">&quot;300px&quot;</span> <span class="attr">height</span>=<span class="string">&quot;180px&quot;</span> <span class="attr">border</span>=<span class="string">&quot;5px&quot;</span></span></span><br><span class="line"><span class="tag">     <span class="attr">alt</span>=<span class="string">&quot;图片路径写错了,去改改吧~&quot;</span> /&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211012172014846.png" alt="image-20211012172014846" style="zoom:50%;border: solid" />    



<ul>
<li>==属性在编写时的注意点 :==<ul>
<li>图片标签有多个属性 , 属性必须写在开始标签中 , 和标签名要有一个空格</li>
<li>属性可以有多个 , 属性之间没有顺序之分 , 但是要空格间隔</li>
<li>属性采取键值对的方式编写 , key=”value” , 属性名 = “属性值”</li>
</ul>
</li>
</ul>
<ul>
<li><p>路径</p>
<ul>
<li><p>目录文件夹和根目录</p>
<p>**目录文件夹 : ** 就是普通的文件夹 , 但是其中存放了网页需要的资源 , 图片 , 视频 , html</p>
<p>**根目录 : ** 打开目录文件的第一层就是根目录</p>
</li>
<li><p><strong>相对路径</strong></p>
<p>以 <strong>引用文件的所在位置</strong> 为参考 , 而创建除的目录路径</p>
<p>简单来说就是 , 资源相对于 html 文件的位置</p>
<table>
<thead>
<tr>
<th>相对路径的分类</th>
<th>符号</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>同级目录</td>
<td>无</td>
<td>资源文件相对于html文件同一层级的 &lt;img src=”img1.jpg” /&gt;</td>
</tr>
<tr>
<td>下一级</td>
<td>/</td>
<td>资源文件相对于html文件下一层级的 &lt;img src=”img/img01.jpg” /&gt;</td>
</tr>
<tr>
<td>上一级</td>
<td>../</td>
<td>资源文件相对于html文件上一层级的 &lt;img src=”../img1.jpg” &gt;</td>
</tr>
</tbody></table>
</li>
<li><p><strong>绝对路径</strong></p>
<p>是指目录下的绝对的位置 , 直达目标 , 通常是盘符</p>
<p>例如 : D:\img01.jpg , 或者是一个完整 <a target="_blank" rel="noopener" href="http://www.baidu.com/img/img01.jpg">http://www.baidu.com/img/img01.jpg</a></p>
</li>
</ul>
</li>
</ul>
<h2 id="7-6-超链接标签"><a href="#7-6-超链接标签" class="headerlink" title="7,6 超链接标签"></a>7,6 超链接标签</h2><p>在html 中使用 , &lt;a&gt; &lt;/a&gt;标签</p>
<p>作用 : 从一个页面链接到另一个页面</p>
<ol>
<li><p>语法</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;跳转的目的地&quot;</span> <span class="attr">target</span>=<span class="string">&quot;开启网页的位置&quot;</span>&gt;</span>文字内容,图片<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure>

<table>
<thead>
<tr>
<th>属性</th>
<th>作用</th>
</tr>
</thead>
<tbody><tr>
<td>href</td>
<td>用于指定链接目标的 url 地址 , (必有属性) 当 a 标签拥有 href 的时候 , 它才具备了超链接的功能</td>
</tr>
<tr>
<td>target</td>
<td>用于指定页面的打开方式 , 默认 <strong>_self</strong> , <strong>_blank</strong> 为新窗口打开</td>
</tr>
</tbody></table>
</li>
<li><p>超链接的几种使用情况</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 内部链接 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;index.html&quot;</span> <span class="attr">target</span>=<span class="string">&quot;_blank&quot;</span>&gt;</span>点击一下,试试吧~<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 外部超链接 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;http://www.baidu.com&quot;</span> <span class="attr">target</span>=<span class="string">&quot;_blank&quot;</span>&gt;</span>百度一下,你就知道<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 空链接 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;&quot;</span> <span class="attr">target</span>=<span class="string">&quot;_blank&quot;</span>&gt;</span>我是空链接<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#&quot;</span> <span class="attr">target</span>=<span class="string">&quot;_blank&quot;</span>&gt;</span>我是空链接<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 下载链接 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;img/demo.zip&quot;</span>&gt;</span>下载压缩包<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 以其他网页元素为内容的超链接 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;index.html&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;img/img01.jpg&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure></li>
<li><p><strong>锚点链接</strong></p>
<p>点击超链接的时候 , 可以快速的定位到网页的指定位置</p>
<ul>
<li>本页面的锚点链接</li>
</ul>
<p>实现锚点的步骤</p>
<p>1, 找到指定位置的标签 , 编写 id 属性和 id属性值</p>
<p>2, 编写超链接标签 , 指定 href 属性属性值为目标标签的id 属性值 , 在属性值之前使用 #</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#center&quot;</span>&gt;</span>前往网页中部<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#bottom&quot;</span>&gt;</span>前往网页底部<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">h1</span> <span class="attr">id</span>=<span class="string">&quot;head&quot;</span>&gt;</span>网页头部<span class="tag">&lt;/<span class="name">h1</span>&gt;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">......</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">h1</span> <span class="attr">id</span>=<span class="string">&quot;center&quot;</span>&gt;</span>网页中部<span class="tag">&lt;/<span class="name">h1</span>&gt;</span></span><br><span class="line"></span><br><span class="line">......</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">h1</span> <span class="attr">id</span>=<span class="string">&quot;bottom&quot;</span>&gt;</span>网页底部<span class="tag">&lt;/<span class="name">h1</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;#head&quot;</span>&gt;</span>回到顶部<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure>

<ul>
<li>跨页面的锚点链接</li>
</ul>
<p>注意点: 超连接的 href 属性内容值格式</p>
<p><strong>目标页面的url # 锚点的id属性值</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- </span></span><br><span class="line"><span class="comment">    跨页面的锚点</span></span><br><span class="line"><span class="comment">    href=&quot;目标页面的url # 锚点的id属性值&quot;</span></span><br><span class="line"><span class="comment">--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;01-HTML常用标签.html#head&quot;</span> <span class="attr">target</span>=<span class="string">&quot;_blank&quot;</span>&gt;</span>前往其他页面顶部<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;01-HTML常用标签.html#center&quot;</span> <span class="attr">target</span>=<span class="string">&quot;_blank&quot;</span>&gt;</span>前往其他页面中部<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;01-HTML常用标签.html#bottom&quot;</span> <span class="attr">target</span>=<span class="string">&quot;_blank&quot;</span>&gt;</span>前往其他页面底部<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure></li>
</ol>
<h1 id="8-特殊字符"><a href="#8-特殊字符" class="headerlink" title="8, 特殊字符"></a>8, 特殊字符</h1><p>作用 : 在网页中一些特殊的符合很难或者不方便直接使用 , 我们可以通过特殊字符进行代替</p>
<p><strong>空格 , 大于小于号</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h1</span>&gt;</span>HTML特殊字符<span class="tag">&lt;/<span class="name">h1</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span>一半角空格:<span class="symbol">&amp;nbsp;</span>|<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span>半个空白位:<span class="symbol">&amp;ensp;</span>|<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span>一个空白位:<span class="symbol">&amp;emsp;</span>|<span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span>一个大于号:<span class="symbol">&amp;gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">div</span>&gt;</span>一个小于号:<span class="symbol">&amp;gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 下面直接使用的&lt;&gt;被浏览器当做 html 标签了 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">hello</span>&gt;</span></span><br><span class="line"><span class="symbol">&amp;lt;</span>hello<span class="symbol">&amp;gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013094747232.png" alt="image-20211013094747232" style="zoom:50%;border: solid" />    



<h1 id="9-表格标签"><a href="#9-表格标签" class="headerlink" title="9, 表格标签"></a>9, 表格标签</h1><h2 id="9-1-表格的结构"><a href="#9-1-表格的结构" class="headerlink" title="9,1 表格的结构"></a>9,1 表格的结构</h2><p>在 HTML 中使用 <strong>table</strong> 标签定义表格</p>
<p>使用 <strong>tr</strong> 标签定义表格的行</p>
<p>使用 <strong>td</strong> 标签定义表格中一行内的单元格</p>
<p>语法:</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">table</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">    	<span class="tag">&lt;<span class="name">td</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    	<span class="tag">&lt;<span class="name">td</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span>        </span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    .......</span><br><span class="line"><span class="tag">&lt;/<span class="name">table</span>&gt;</span></span><br></pre></td></tr></table></figure>

<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- </span></span><br><span class="line"><span class="comment">    定义:3行4列</span></span><br><span class="line"><span class="comment">    3行: tr有3个</span></span><br><span class="line"><span class="comment">    4列: 1个tr中有4个td</span></span><br><span class="line"><span class="comment">--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">table</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>学号<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>姓名<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>性别<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>年龄<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>1<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>张三<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>男<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>21<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>2<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>李四<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>女<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>20<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">table</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013095636446.png" alt="image-20211013095636446" style="zoom:50%;" />    



<ul>
<li><p>表格的表头标签</p>
<p>作用 : 表示列头部 , 一行的头部 , 显示在其中的文字会有<strong>加粗和居中</strong>的效果</p>
<p>本质和 td 没有区别 , 以代表者一行的一个单元格</p>
</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">table</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">th</span>&gt;</span>学号<span class="tag">&lt;/<span class="name">th</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">th</span>&gt;</span>姓名<span class="tag">&lt;/<span class="name">th</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">th</span>&gt;</span>性别<span class="tag">&lt;/<span class="name">th</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">th</span>&gt;</span>年龄<span class="tag">&lt;/<span class="name">th</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>1<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>汤米谢尔比<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>男<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>21<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>2<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>李四<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>女<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>20<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">table</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013100026052.png" alt="image-20211013100026052" style="zoom:50%;border: solid" />    



<h2 id="9-2-表格的属性"><a href="#9-2-表格的属性" class="headerlink" title="9,2 表格的属性"></a>9,2 表格的属性</h2><table>
<thead>
<tr>
<th>属性名</th>
<th>属性值</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>align</td>
<td>left(默认) ; right ; center</td>
<td>规定表格相对于周围元素的对齐方式</td>
</tr>
<tr>
<td>border</td>
<td>像素</td>
<td>用于规定表格的边框的粗细 , 默认是没有边框的 , 属性值 =””</td>
</tr>
<tr>
<td>width</td>
<td>像素或百分比</td>
<td>规定表格的宽度 , 百分比相对于浏览器</td>
</tr>
<tr>
<td>height</td>
<td>像素或百分比</td>
<td>规定表格的宽度 , 百分比相对于父元素</td>
</tr>
<tr>
<td>cellpadding</td>
<td>像素</td>
<td>规定单元格边框于内容之间的距离 , 默认 1 px</td>
</tr>
<tr>
<td>cellspacing</td>
<td>像素</td>
<td>规定单元格和单元格之间的距离 , 默认 2 px</td>
</tr>
<tr>
<td>bgcolor</td>
<td>单词, rgb(), 16进制取色</td>
<td>规定表格 , 行 , 单元格的背景颜色</td>
</tr>
</tbody></table>
<blockquote>
<p>代码实例</p>
</blockquote>
<ul>
<li><p>align , border , width , height , bgcolor</p>
<p>注意 1 : align 属性写在 table 标签中 , 控制表格位于浏览器中的对齐位置 , 写在 tr 或者是 td 中 , 控制的是表格内容的对齐方式</p>
<p>注意 2 : bgcolor 写在 table 中 控制整个表格的颜色 , 写在 tr 或者 td , 控制的是一行或者一列的颜色</p>
</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">table</span> <span class="attr">align</span>=<span class="string">&quot;center&quot;</span> <span class="attr">border</span>=<span class="string">&quot;1px&quot;</span> <span class="attr">width</span>=<span class="string">&quot;400px&quot;</span> <span class="attr">height</span>=<span class="string">&quot;200px&quot;</span></span></span><br><span class="line"><span class="tag">       <span class="attr">bgcolor</span>=<span class="string">&quot;aqua&quot;</span> &gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span> <span class="attr">bgcolor</span>=<span class="string">&quot;burlywood&quot;</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">th</span>&gt;</span>学号<span class="tag">&lt;/<span class="name">th</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">th</span>&gt;</span>姓名<span class="tag">&lt;/<span class="name">th</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">th</span>&gt;</span>性别<span class="tag">&lt;/<span class="name">th</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">th</span>&gt;</span>年龄<span class="tag">&lt;/<span class="name">th</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span> <span class="attr">bgcolor</span>=<span class="string">&quot;chartreuse&quot;</span> <span class="attr">align</span>=<span class="string">&quot;center&quot;</span>&gt;</span>1<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>汤米谢尔比<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>男<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>21<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>  <span class="attr">align</span>=<span class="string">&quot;center&quot;</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>2<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>李四<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>女<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>20<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">table</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013101432157.png" alt="image-20211013101432157" style="zoom:40%;" />    

<ul>
<li>cellspacing , cellpadding</li>
</ul>
<p>==注意: 表格如果存在宽高,cellpadding 控制的是表格边框左侧到内容的距离==</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>3 x 3 表格<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 注意: 表格如果存在宽高,cellpadding 控制的是表格边框左侧到内容的距离 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">table</span> <span class="attr">border</span>=<span class="string">&quot;1px&quot;</span> <span class="attr">cellspacing</span>=<span class="string">&quot;10px&quot;</span> <span class="attr">cellpadding</span>=<span class="string">&quot;10px&quot;</span> <span class="attr">width</span>=<span class="string">&quot;300px&quot;</span> </span></span><br><span class="line"><span class="tag">       <span class="attr">height</span>=<span class="string">&quot;300px&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>学号<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>姓名<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>性别<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>1<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>王五<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>男<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>2<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>赵六<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span>女<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">table</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013102258840.png" alt="image-20211013102258840" style="zoom:50%;" />    



<h2 id="9-3-表格结构化标签"><a href="#9-3-表格结构化标签" class="headerlink" title="9,3 表格结构化标签"></a>9,3 表格结构化标签</h2><ul>
<li>**thead : **用于定义表格结构的头部</li>
<li>**tbody : **用于定义表格结构的主体</li>
<li>**tfoot : **用于定义表格结构的底部</li>
</ul>
<p>注意 : 要在 table 中使用</p>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 定义一个5行3列的表格,表头1行,主体3行,底部1行 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">table</span> <span class="attr">border</span>=<span class="string">&quot;1px&quot;</span> <span class="attr">width</span>=<span class="string">&quot;300px&quot;</span> <span class="attr">height</span>=<span class="string">&quot;500px&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">thead</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>学号<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>姓名<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>性别<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">thead</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- 3行 --&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tbody</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>1<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>张三<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>男<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>2<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>李四<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>女<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>3<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>王五<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>男<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tbody</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tfoot</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>总数<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>合计<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">td</span>&gt;</span>总和<span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tfoot</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">table</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013104400161.png" alt="image-20211013104400161" style="zoom:50%;" />    



<h2 id="9-4-表格合并单元格"><a href="#9-4-表格合并单元格" class="headerlink" title="9,4 表格合并单元格"></a>9,4 表格合并单元格</h2><ul>
<li><p><strong>两种情况</strong></p>
<ul>
<li>跨行合并 : rowspan=”合并的行数”</li>
<li>跨列合并 : colspan=”合并的列数”</li>
</ul>
</li>
<li><p>目标单元格</p>
<ul>
<li><p>跨行 : 最上方的单元格为目标单元格 , 写合并的代码 , 从上向下</p>
</li>
<li><p>跨列 : 最左方的单元格为目标单元格 , 写合并的代码 , 从左向右</p>
<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013104815495.png" alt="image-20211013104815495" style="zoom:50%;border: solid" />    </li>
</ul>
</li>
<li><p><strong>步骤</strong></p>
<p>第一步 : 先要确定合并的方式</p>
<p>第二步 : 找到目标单元格 , 编写 colspan 或者 rowspan , 写好属性值</p>
<p>第三步 : 删除多余单元格</p>
<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013105117548.png" alt="image-20211013105117548" style="zoom:67%;" />    

<p>进行合并的操作 , 第1行第2个单元格 (第1个tr中第2个td) 为目标单元格 , 在此处编写合并列代码</p>
<p>第2行第2个单元格 (第2个tr中第2个td) 为目标单元格 , 在此处编写合并行代码</p>
</li>
</ul>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>合并单元格<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">table</span> <span class="attr">width</span>=<span class="string">&quot;300px&quot;</span> <span class="attr">height</span>=<span class="string">&quot;300px&quot;</span> <span class="attr">border</span>=<span class="string">&quot;1px&quot;</span> <span class="attr">cellspacing</span>=<span class="string">&quot;0&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span> <span class="attr">colspan</span>=<span class="string">&quot;2&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span> <span class="attr">rowspan</span>=<span class="string">&quot;2&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">table</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013105933416.png" alt="image-20211013105933416" style="zoom: 50%;" />    





<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">table</span> <span class="attr">width</span>=<span class="string">&quot;500px&quot;</span> <span class="attr">height</span>=<span class="string">&quot;500px&quot;</span> <span class="attr">border</span>=<span class="string">&quot;1px&quot;</span> <span class="attr">cellspacing</span>=<span class="string">&quot;0&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span> <span class="attr">colspan</span>=<span class="string">&quot;4&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span> <span class="attr">rowspan</span>=<span class="string">&quot;4&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span> <span class="attr">rowspan</span>=<span class="string">&quot;4&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span> <span class="attr">colspan</span>=<span class="string">&quot;2&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span> <span class="attr">rowspan</span>=<span class="string">&quot;2&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span> <span class="attr">rowspan</span>=<span class="string">&quot;2&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span> <span class="attr">colspan</span>=<span class="string">&quot;2&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">tr</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">td</span> <span class="attr">colspan</span>=<span class="string">&quot;4&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">td</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">tr</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">table</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>​    <img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013111825400.png" alt="image-20211013111825400" style="zoom: 50%;" />    </p>
<h1 id="10-列表标签"><a href="#10-列表标签" class="headerlink" title="10, 列表标签"></a>10, 列表标签</h1><p>作用 : 显示数据 , <strong>布局</strong></p>
<ul>
<li>三种<ul>
<li>有序 ： <strong>ol , li</strong></li>
<li>无序 ： <strong>ul , li</strong></li>
<li>自定义 ：<strong>dl , dt , dd</strong></li>
</ul>
</li>
</ul>
<blockquote>
<p>代码实例</p>
</blockquote>
<ul>
<li><p>属性 : <strong>type</strong></p>
<p>作用 : 规定有序或者无序列表表头的样式</p>
<p>属性值 :</p>
<p>有序 : 1 , a , A , i , I</p>
<p>无序 : circle(空心圆) , disc(实心点) , square(方块)</p>
</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>有序列表<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">ol</span> <span class="attr">type</span>=<span class="string">&quot;I&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span>&gt;</span>Java<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span>&gt;</span>Oracle<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span>&gt;</span>html<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span>&gt;</span>css<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span>&gt;</span>框架</span><br><span class="line">        <span class="tag">&lt;<span class="name">ol</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span>spring<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span>springMVC<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span>.net core<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">ol</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">ol</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>无序列表<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">ul</span> <span class="attr">type</span>=<span class="string">&quot;square&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span>&gt;</span>Java<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span>&gt;</span>Oracle<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span>&gt;</span>html<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span>&gt;</span>css<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span>&gt;</span>框架</span><br><span class="line">        <span class="tag">&lt;<span class="name">ul</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span>spring<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span>springMVC<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">li</span>&gt;</span>.net core<span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">ul</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">ul</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013113200155.png" alt="image-20211013113200155" style="zoom:50%;border: solid" />    



<ul>
<li>自定义列表</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>自定义列表<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- </span></span><br><span class="line"><span class="comment">    dl:定义自定义列表</span></span><br><span class="line"><span class="comment">    dt:定义列表的标题</span></span><br><span class="line"><span class="comment">    dd:定义列表的内容</span></span><br><span class="line"><span class="comment">--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dl</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">dt</span>&gt;</span>前端<span class="tag">&lt;/<span class="name">dt</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">dd</span>&gt;</span>HTML<span class="tag">&lt;/<span class="name">dd</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">dd</span>&gt;</span>CSS<span class="tag">&lt;/<span class="name">dd</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">dd</span>&gt;</span>JavaScript<span class="tag">&lt;/<span class="name">dd</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">dd</span>&gt;</span>jQuery<span class="tag">&lt;/<span class="name">dd</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="tag">&lt;<span class="name">dt</span>&gt;</span>服务端<span class="tag">&lt;/<span class="name">dt</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">dd</span>&gt;</span>Java<span class="tag">&lt;/<span class="name">dd</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">dd</span>&gt;</span>C#<span class="tag">&lt;/<span class="name">dd</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">dd</span>&gt;</span>PHP<span class="tag">&lt;/<span class="name">dd</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">dd</span>&gt;</span>Node.js<span class="tag">&lt;/<span class="name">dd</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dl</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013134857936.png" alt="image-20211013134857936" style="zoom: 50%;border: solid" />    

<ul>
<li><p>总结 :</p>
<p>列表的作用主要用于布局 , 应为列表的特点 , 整齐 , 有序 , 他会让布局更加方便</p>
<ul>
<li>ol 和 ul 中只能使用 li 标签</li>
<li>li 相当于一个容器 , 可以容纳所有的元素</li>
<li>列表的表头符号后期通过 CSS 样式进行修改</li>
</ul>
<p>使用频率最高的事 ul</p>
</li>
</ul>
<h1 id="11-表单"><a href="#11-表单" class="headerlink" title="11, 表单"></a>11, 表单</h1><h2 id="11-1-什么是表单"><a href="#11-1-什么是表单" class="headerlink" title="11,1 什么是表单"></a>11,1 什么是表单</h2><p>在项目当中 , 注册的功能 , 登录的功能…..</p>
<p>使用表单的目的为了<strong>收集用户的信息 , 完成用户的注册</strong></p>
<h2 id="11-2-表单的组成"><a href="#11-2-表单的组成" class="headerlink" title="11,2 表单的组成"></a>11,2 表单的组成</h2><ul>
<li><strong>表单域 : 编写表单元素的区域 , 可以实现表单信息提交的功能</strong></li>
<li><strong>表单元素 : 表单标签 , 表单控件 : 按钮 , 输入框 , 下拉列表</strong></li>
<li><strong>提示信息 : 提示用户表单元素提交的内容</strong></li>
</ul>
<h2 id="11-3-input表单元素"><a href="#11-3-input表单元素" class="headerlink" title="11,3 input表单元素"></a>11,3 input表单元素</h2><p>input 有很多不同的功能 , 通过 type 属性进行功能的切换</p>
<p>也就是 type 属性值不同 , input 在网页中的功能和表现形式就不同</p>
<ul>
<li>文本框 , 密码框 , 隐藏域</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- </span></span><br><span class="line"><span class="comment">    value:元素的值,在此处可以理解为文本框的默认值</span></span><br><span class="line"><span class="comment">    type:当属性值为 text 的时候,input为文本输入框</span></span><br><span class="line"><span class="comment">    placeholder:文本框中的提示信息,在输入内容后就消失</span></span><br><span class="line"><span class="comment">    注意点: placeholder和value最好不要一同使用</span></span><br><span class="line"><span class="comment">    因为 value 会覆盖掉 placeholder 内容</span></span><br><span class="line"><span class="comment">--&gt;</span></span><br><span class="line">用户名:<span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">name</span>=<span class="string">&quot;username&quot;</span> <span class="attr">id</span>=<span class="string">&quot;un&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;请输入用户名...&quot;</span> <span class="attr">value</span>=<span class="string">&quot;张三&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">br</span> /&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- </span></span><br><span class="line"><span class="comment">    type属性值为 password 时, input 为密码框</span></span><br><span class="line"><span class="comment">    密码框中国年输入的内容全部为实心点</span></span><br><span class="line"><span class="comment">--&gt;</span></span><br><span class="line">密<span class="symbol">&amp;emsp;</span>码:<span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;password&quot;</span> <span class="attr">name</span>=<span class="string">&quot;password&quot;</span> <span class="attr">id</span>=<span class="string">&quot;pwd&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;请输入密码...&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">br</span> /&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- </span></span><br><span class="line"><span class="comment">    type属性值为 hidden 时, input标签为隐藏域</span></span><br><span class="line"><span class="comment">    用于设置用户的无法修改的信息,比如用户等级,权限</span></span><br><span class="line"><span class="comment">--&gt;</span></span><br><span class="line">隐藏域:<span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;hidden&quot;</span> <span class="attr">name</span>=<span class="string">&quot;level&quot;</span> <span class="attr">id</span>=<span class="string">&quot;lev&quot;</span> <span class="attr">value</span>=<span class="string">&quot;0&quot;</span> /&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013142544554.png" alt="image-20211013142544554" style="zoom:50%;border: solid" />    



<ul>
<li><p>单选按钮 , 多选按钮</p>
<ul>
<li><p>单选按钮 : **type属性值为 radio **</p>
<p>==如果需要实现单选的功能 , 必须指定单选按钮的 name 属性值相同==</p>
</li>
<li><p>多选按钮 : <strong>type属性值为 chexkbox , 也被称作为复选框</strong></p>
<p>==建议同一内容下的复选框的name属性值一致==</p>
</li>
</ul>
<p>如果需要默认选择的按钮选项 , 为对应的标签添加 <strong>checked</strong> 属性 , 属性值为 <strong>checked</strong> , 属性值可以不写</p>
</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>单选&amp;多选按钮<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line">性<span class="symbol">&amp;emsp;</span>别:</span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;gender&quot;</span> <span class="attr">id</span>=<span class="string">&quot;boy&quot;</span> <span class="attr">value</span>=<span class="string">&quot;boy&quot;</span> /&gt;</span>男</span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;gender&quot;</span> <span class="attr">id</span>=<span class="string">&quot;girl&quot;</span> <span class="attr">value</span>=<span class="string">&quot;girl&quot;</span> <span class="attr">checked</span>=<span class="string">&quot;checked&quot;</span> /&gt;</span>女</span><br><span class="line"><span class="tag">&lt;<span class="name">br</span> /&gt;</span></span><br><span class="line">技术能力:</span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;checkbox&quot;</span> <span class="attr">name</span>=<span class="string">&quot;skill&quot;</span> <span class="attr">id</span>=<span class="string">&quot;web&quot;</span> <span class="attr">value</span>=<span class="string">&quot;101&quot;</span> <span class="attr">checked</span> /&gt;</span>前端研发</span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;checkbox&quot;</span> <span class="attr">name</span>=<span class="string">&quot;skill&quot;</span> <span class="attr">id</span>=<span class="string">&quot;server&quot;</span> <span class="attr">value</span>=<span class="string">&quot;102&quot;</span> /&gt;</span>服务端研发</span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;checkbox&quot;</span> <span class="attr">name</span>=<span class="string">&quot;skill&quot;</span> <span class="attr">id</span>=<span class="string">&quot;middle&quot;</span> <span class="attr">value</span>=<span class="string">&quot;103&quot;</span> /&gt;</span>中间件研发</span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013145254323.png" alt="image-20211013145254323" style="zoom:50%;border: solid" />    



<ul>
<li><strong>input 的其他属性</strong><ul>
<li>name : 用户自定义 , 作用是定义元素名字 , 用于传值 , 命名要有意义  , 不要中文</li>
<li>value : 定义元素的值 , 对应 name 属性 , 表单提交是的元素传递的值</li>
<li><strong>==maxlength : 定义文本框中输入内容的最大 , 能向文本框中写入多少个字符==</strong></li>
<li><strong>==size : 设置文本框的尺寸 , 属性值为像素==</strong></li>
</ul>
</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>maxlength &amp; size 属性<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">h5</span>&gt;</span>长文本框<span class="tag">&lt;/<span class="name">h5</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">maxlength</span>=<span class="string">&quot;15&quot;</span> <span class="attr">size</span>=<span class="string">&quot;20px&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">h5</span>&gt;</span>中文本框<span class="tag">&lt;/<span class="name">h5</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">maxlength</span>=<span class="string">&quot;10&quot;</span> <span class="attr">size</span>=<span class="string">&quot;15px&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">h5</span>&gt;</span>小文本框<span class="tag">&lt;/<span class="name">h5</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">maxlength</span>=<span class="string">&quot;5&quot;</span> <span class="attr">size</span>=<span class="string">&quot;10px&quot;</span> /&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013150406368.png" alt="image-20211013150406368" style="zoom:50%;border: solid" />    



<ul>
<li><p>文件域 , 数字框 , 搜索框</p>
<ul>
<li><p><strong>文件域 : type 属性值为 file , 用于上传文件</strong></p>
</li>
<li><p><strong>数字框 : type 属性值为 number , 限制文本框中的内容为数字内容</strong></p>
<p>特有属性</p>
<ul>
<li>**min : **设置数字框的最小值</li>
<li>**max : **设置数字框的最大值</li>
<li>**step : **设置数字框右侧按钮的增减量</li>
</ul>
</li>
<li><p><strong>搜索框 : type属性值为 search ,  和文本没有本质区别 , 比文本框多一个清楚内容的按钮</strong></p>
</li>
</ul>
</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>文件域, 数字框, 搜索框<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line">上传简历:<span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;file&quot;</span> <span class="attr">name</span>=<span class="string">&quot;file&quot;</span> <span class="attr">id</span>=<span class="string">&quot;file&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">br</span> /&gt;</span></span><br><span class="line">数字框:<span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;number&quot;</span> <span class="attr">name</span>=<span class="string">&quot;num&quot;</span> <span class="attr">id</span>=<span class="string">&quot;num&quot;</span>  <span class="attr">max</span>=<span class="string">&quot;100&quot;</span> <span class="attr">min</span>=<span class="string">&quot;1&quot;</span> <span class="attr">step</span>=<span class="string">&quot;10&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">br</span> /&gt;</span></span><br><span class="line">搜索框:<span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;search&quot;</span> <span class="attr">name</span>=<span class="string">&quot;search&quot;</span> <span class="attr">id</span>=<span class="string">&quot;sea&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;请输入搜索的信息&quot;</span> /&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013151610017.png" alt="image-20211013151610017" style="zoom:50%;border: solid" />    



<h2 id="11-4-label标签"><a href="#11-4-label标签" class="headerlink" title="11,4 label标签"></a>11,4 label标签</h2><p>作用 : 绑定表单元素和提示信息</p>
<p><strong>优点 :</strong></p>
<ul>
<li>让独立在外的提示信息和表单元素产生链接</li>
<li>增强了鼠标的可用性</li>
</ul>
<p><strong>使用的步骤 :</strong></p>
<ol>
<li>使用 label 标签将提示信息包括起来</li>
<li>指定表单元素的 id 属性 , 并编写属性值</li>
<li>将 label 中 for 属性的属性值填写为对应的表单元素的 id 属性值</li>
</ol>
<p>**效果 : **</p>
<p>当用户点击被 label 标签包括的提示信息时 , 鼠标的光标会出现在指定的表单元素中</p>
<p>点击对应的提示信息 , 就是选中了对应的标签</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>label 标签<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">label</span> <span class="attr">for</span>=<span class="string">&quot;un2&quot;</span>&gt;</span>用户名:<span class="tag">&lt;/<span class="name">label</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">name</span>=<span class="string">&quot;username&quot;</span> <span class="attr">id</span>=<span class="string">&quot;un2&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;请输入用户名...&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">br</span> /&gt;</span></span><br><span class="line">性别:</span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;gender&quot;</span> <span class="attr">id</span>=<span class="string">&quot;boy2&quot;</span> <span class="attr">value</span>=<span class="string">&quot;1&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">label</span> <span class="attr">for</span>=<span class="string">&quot;boy2&quot;</span>&gt;</span>男<span class="tag">&lt;/<span class="name">label</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;radio&quot;</span> <span class="attr">name</span>=<span class="string">&quot;gender&quot;</span> <span class="attr">id</span>=<span class="string">&quot;girl2&quot;</span> <span class="attr">value</span>=<span class="string">&quot;0&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">label</span> <span class="attr">for</span>=<span class="string">&quot;girl2&quot;</span>&gt;</span>女<span class="tag">&lt;/<span class="name">label</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>==注意 : label 标签的 for 属性值 和 对应表单元素的 id 属性值一定要一致==</p>
<h2 id="11-5-下拉列表"><a href="#11-5-下拉列表" class="headerlink" title="11,5 下拉列表"></a>11,5 下拉列表</h2><p>在 HTML 中 使用 <strong>select</strong> 定义表中的下拉列表</p>
<p>使用 <strong>option</strong> 定义下拉列表中的一项内容</p>
<p><strong>option</strong> 标签中设置默认选择项 : selected</p>
<p>属性值只有一个 selected , 可以不写</p>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>下拉列表<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line">地址:</span><br><span class="line"><span class="tag">&lt;<span class="name">select</span> <span class="attr">name</span>=<span class="string">&quot;address&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;DL&quot;</span>&gt;</span>大连<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;LY&quot;</span>&gt;</span>辽阳<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;SY&quot;</span>&gt;</span>沈阳<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;TL&quot;</span>&gt;</span>铁岭<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;YK&quot;</span>&gt;</span>营口<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span> =<span class="string">&quot;0&quot;</span> <span class="attr">selected</span>=<span class="string">&quot;selected&quot;</span>&gt;</span>----请选择地址----<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">select</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013160000353.png" alt="image-20211013160000353" style="zoom:50%;border: solid" />    



<ul>
<li><p>对下拉列表中的内容进行分组</p>
<p>使用 <strong>optgroup</strong> 标签</p>
<p><strong>label 属性: 分组的组名 , 不可被选择的</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">籍贯:</span><br><span class="line"><span class="tag">&lt;<span class="name">select</span> <span class="attr">name</span>=<span class="string">&quot;hometown&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">optgroup</span> <span class="attr">label</span>=<span class="string">&quot;辽宁&quot;</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;DL&quot;</span>&gt;</span>大连<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;LY&quot;</span>&gt;</span>辽阳<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;SY&quot;</span>&gt;</span>沈阳<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">optgroup</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">optgroup</span> <span class="attr">label</span>=<span class="string">&quot;河北&quot;</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;SJZ&quot;</span>&gt;</span>石家庄<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;TS&quot;</span>&gt;</span>唐山<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;HD&quot;</span>&gt;</span>邯郸<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">optgroup</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span> =<span class="string">&quot;0&quot;</span> <span class="attr">selected</span>=<span class="string">&quot;selected&quot;</span>&gt;</span>----请选择地址----<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">select</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013160750373.png" alt="image-20211013160750373" style="zoom:50%;border:solid" />    </li>
</ul>
<h2 id="11-6-表单域"><a href="#11-6-表单域" class="headerlink" title="11,6 表单域"></a>11,6 表单域</h2><p>包含表单元素的区域 , 在HTML中使用 <strong>form</strong> 标签来定义表单域</p>
<p>如果需要实现表单提交的功能 , <strong>必要的 2 个条件</strong></p>
<ol>
<li>表单元素要在表单域中</li>
<li>需要 “ 提交的按钮 “</li>
</ol>
<ul>
<li><strong>表单的属性 :</strong></li>
</ul>
<ol>
<li>**action : **表单提交的地址 , 可以是网站 , 可以是一个处理请求的程序</li>
<li>**method : **表单提交的方式<ul>
<li><strong>get</strong></li>
<li><strong>post</strong></li>
</ul>
</li>
</ol>
<ul>
<li><p><strong>input 按钮 : 通过切换type 属性值 , 切换按钮的功能</strong></p>
<ul>
<li>**button : **仅仅只有按钮的样式 , 没有提交的功能 , 通过事件引入脚本</li>
<li>**submit : **有提交功能的按钮</li>
<li>**reset : **重置表单中所有信息 , 恢复默认值</li>
<li>**image : ** 图片按钮 , 默认提交 , 拥有和 img 标签相同的属性</li>
</ul>
<p>==定义按钮后的input标签的 value 属性 , 是按钮上的提示信息==</p>
</li>
</ul>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">form</span> <span class="attr">action</span>=<span class="string">&quot;02-table.html&quot;</span> <span class="attr">method</span>=<span class="string">&quot;get&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">        用户名: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">name</span>=<span class="string">&quot;username&quot;</span> <span class="attr">id</span>=<span class="string">&quot;un&quot;</span> </span></span><br><span class="line"><span class="tag">        <span class="attr">placeholder</span>=<span class="string">&quot;请输入用户名称...&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">        密<span class="symbol">&amp;emsp;</span>码: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;password&quot;</span> <span class="attr">name</span>=<span class="string">&quot;password&quot;</span> <span class="attr">id</span>=<span class="string">&quot;pwd&quot;</span> </span></span><br><span class="line"><span class="tag">        <span class="attr">placeholder</span>=<span class="string">&quot;请输入密码...&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;button&quot;</span> <span class="attr">value</span>=<span class="string">&quot;button按钮&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;submit&quot;</span> <span class="attr">value</span>=<span class="string">&quot;submit按钮&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;reset&quot;</span> <span class="attr">value</span>=<span class="string">&quot;reset按钮&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;image&quot;</span> <span class="attr">src</span>=<span class="string">&quot;img/img01.jpg&quot;</span> <span class="attr">width</span>=<span class="string">&quot;100&quot;</span> <span class="attr">height</span>=<span class="string">&quot;50&quot;</span> </span></span><br><span class="line"><span class="tag">    <span class="attr">title</span>=<span class="string">&quot;点我提交~~&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">form</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013162715026.png" alt="image-20211013162715026" style="zoom:50%;border: solid" />    



<h2 id="11-7-表单提交的方式"><a href="#11-7-表单提交的方式" class="headerlink" title="11,7 表单提交的方式"></a>11,7 表单提交的方式</h2><p>表单提交的方式 : 通过 <strong>method</strong> 设置</p>
<p>表单提交的数据通过 name 值 对应 value 值进行提交的</p>
<p>表单提交数据是元素的 value 值 而不是提示信息 </p>
<ul>
<li><strong>get</strong></li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">form</span> <span class="attr">action</span>=<span class="string">&quot;02-table.html&quot;</span> <span class="attr">method</span>=<span class="string">&quot;get&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">        用户名: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">name</span>=<span class="string">&quot;username&quot;</span> <span class="attr">id</span>=<span class="string">&quot;un&quot;</span> </span></span><br><span class="line"><span class="tag">                    <span class="attr">placeholder</span>=<span class="string">&quot;请输入用户名称...&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">        密<span class="symbol">&amp;emsp;</span>码: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;password&quot;</span> <span class="attr">name</span>=<span class="string">&quot;password&quot;</span> <span class="attr">id</span>=<span class="string">&quot;pwd&quot;</span> </span></span><br><span class="line"><span class="tag">                         <span class="attr">placeholder</span>=<span class="string">&quot;请输入密码...&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;button&quot;</span> <span class="attr">value</span>=<span class="string">&quot;button按钮&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;submit&quot;</span> <span class="attr">value</span>=<span class="string">&quot;submit按钮&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;reset&quot;</span> <span class="attr">value</span>=<span class="string">&quot;reset按钮&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;image&quot;</span> <span class="attr">src</span>=<span class="string">&quot;img/img01.jpg&quot;</span> <span class="attr">width</span>=<span class="string">&quot;100&quot;</span> <span class="attr">height</span>=<span class="string">&quot;50&quot;</span> </span></span><br><span class="line"><span class="tag">           <span class="attr">title</span>=<span class="string">&quot;点我提交~~&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">form</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>get提交方式特点 :</strong></p>
<ol>
<li><p>get 方式会将数据显示在地址栏中 , 数据**==不安全==**</p>
</li>
<li><p>只能**==提交少量的数据==** , 收到地址栏长度的限制 , 只能提交不超过 2048个字符的信息 (2KB)</p>
<p><img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source_posts\01-HTML.assets\image-20211013163321409.png" alt="image-20211013163321409">    </p>
</li>
</ol>
<ul>
<li><strong>post</strong></li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">form</span> <span class="attr">action</span>=<span class="string">&quot;02-table.html&quot;</span> <span class="attr">method</span>=<span class="string">&quot;post&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">        用户名: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">name</span>=<span class="string">&quot;username&quot;</span> <span class="attr">id</span>=<span class="string">&quot;un&quot;</span> </span></span><br><span class="line"><span class="tag">        <span class="attr">placeholder</span>=<span class="string">&quot;请输入用户名称...&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">        密<span class="symbol">&amp;emsp;</span>码: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;password&quot;</span> <span class="attr">name</span>=<span class="string">&quot;password&quot;</span> <span class="attr">id</span>=<span class="string">&quot;pwd&quot;</span> </span></span><br><span class="line"><span class="tag">        <span class="attr">placeholder</span>=<span class="string">&quot;请输入密码...&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;button&quot;</span> <span class="attr">value</span>=<span class="string">&quot;button按钮&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;submit&quot;</span> <span class="attr">value</span>=<span class="string">&quot;submit按钮&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;reset&quot;</span> <span class="attr">value</span>=<span class="string">&quot;reset按钮&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;image&quot;</span> <span class="attr">src</span>=<span class="string">&quot;img/img01.jpg&quot;</span> <span class="attr">width</span>=<span class="string">&quot;100&quot;</span> <span class="attr">height</span>=<span class="string">&quot;50&quot;</span> </span></span><br><span class="line"><span class="tag">    <span class="attr">title</span>=<span class="string">&quot;点我提交~~&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">form</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>post提交方式特点 :</strong></p>
<ol>
<li>post 方式会将数据不显示在地址栏中 , <strong>==数据安全==</strong></li>
<li><strong>==能提交大量的数据==</strong> , 不受地址栏长度的限制</li>
</ol>
<h2 id="11-8-button标签"><a href="#11-8-button标签" class="headerlink" title="11,8 button标签"></a>11,8 button标签</h2><ul>
<li><p><strong>type属性 : 通过切换 type 属性值 , 切换按钮的功能</strong></p>
<ul>
<li>button</li>
<li>reset</li>
<li>submit , 在表单中默认是提交的 (Chrome)</li>
</ul>
</li>
<li><p><strong>button按钮可在不在表单域情况 , 控制表单</strong></p>
<p>通过对应的属性 :</p>
<ul>
<li>form : 规定按钮属于哪个表单 , 属性值对应表单的 id 属性值</li>
<li>formaction : 控制对应表单的提交地址</li>
<li>formmethod : 控制对应表单的提交方式</li>
</ul>
</li>
</ul>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">form</span> <span class="attr">id</span>=<span class="string">&quot;aa&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">        用户名: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">name</span>=<span class="string">&quot;username&quot;</span> <span class="attr">id</span>=<span class="string">&quot;un&quot;</span> </span></span><br><span class="line"><span class="tag">        <span class="attr">placeholder</span>=<span class="string">&quot;请输入用户名称...&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">        密<span class="symbol">&amp;emsp;</span>码: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;password&quot;</span> <span class="attr">name</span>=<span class="string">&quot;password&quot;</span> <span class="attr">id</span>=<span class="string">&quot;pwd&quot;</span> </span></span><br><span class="line"><span class="tag">        <span class="attr">placeholder</span>=<span class="string">&quot;请输入密码...&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">form</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">button</span> <span class="attr">type</span>=<span class="string">&quot;button&quot;</span>&gt;</span>button按钮<span class="tag">&lt;/<span class="name">button</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">button</span> <span class="attr">type</span>=<span class="string">&quot;submit&quot;</span> <span class="attr">form</span>=<span class="string">&quot;aa&quot;</span> <span class="attr">formaction</span>=<span class="string">&quot;02-table.html&quot;</span> <span class="attr">formmethod</span>=<span class="string">&quot;get&quot;</span> &gt;</span></span><br><span class="line">    submit按钮<span class="tag">&lt;/<span class="name">button</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">button</span> <span class="attr">type</span>=<span class="string">&quot;reset&quot;</span> <span class="attr">form</span>=<span class="string">&quot;aa&quot;</span>&gt;</span>reset按钮<span class="tag">&lt;/<span class="name">button</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">button</span> <span class="attr">type</span>=<span class="string">&quot;submit&quot;</span> <span class="attr">form</span>=<span class="string">&quot;aa&quot;</span> <span class="attr">formaction</span>=<span class="string">&quot;02-table.html&quot;</span> <span class="attr">formmethod</span>=<span class="string">&quot;get&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">&quot;img/renren.gif&quot;</span> <span class="attr">width</span>=<span class="string">&quot;100px&quot;</span> <span class="attr">height</span>=<span class="string">&quot;25px&quot;</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">button</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013170530484.png" alt="image-20211013170530484" style="zoom:50%;border:solid" />    

<p><strong>==注意点 : 请始终为 button 标签设置 type , 不同的浏览器默认的type属性值不同==</strong></p>
<h2 id="11-9-表单的结构标签"><a href="#11-9-表单的结构标签" class="headerlink" title="11,9 表单的结构标签"></a>11,9 表单的结构标签</h2><p>表单的语义标签 : 明确表单元素的分类</p>
<ul>
<li><strong>fieldset : 为表单内容分组</strong></li>
<li><strong>legend : 为分组的内容命名</strong></li>
</ul>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>表单的结构标签<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">form</span> <span class="attr">action</span>=<span class="string">&quot;02-table.html&quot;</span> <span class="attr">method</span>=<span class="string">&quot;get&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">fieldset</span> <span class="attr">id</span>=<span class="string">&quot;info&quot;</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">legend</span>&gt;</span>用户信息<span class="tag">&lt;/<span class="name">legend</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">            用户名: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">name</span>=<span class="string">&quot;username&quot;</span> <span class="attr">id</span>=<span class="string">&quot;un&quot;</span> </span></span><br><span class="line"><span class="tag">            <span class="attr">placeholder</span>=<span class="string">&quot;请输入用户名称...&quot;</span> /&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">            密<span class="symbol">&amp;emsp;</span>码: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;password&quot;</span> <span class="attr">name</span>=<span class="string">&quot;password&quot;</span> <span class="attr">id</span>=<span class="string">&quot;pwd&quot;</span> </span></span><br><span class="line"><span class="tag">            <span class="attr">placeholder</span>=<span class="string">&quot;请输入密码...&quot;</span> /&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">fieldset</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">fieldset</span> <span class="attr">id</span>=<span class="string">&quot;connect&quot;</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">legend</span>&gt;</span>联系方式<span class="tag">&lt;/<span class="name">legend</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">            电<span class="symbol">&amp;emsp;</span>话: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">name</span>=<span class="string">&quot;phone&quot;</span> <span class="attr">id</span>=<span class="string">&quot;pho&quot;</span> </span></span><br><span class="line"><span class="tag">            <span class="attr">placeholder</span>=<span class="string">&quot;请输入您的电话...&quot;</span> /&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">            邮<span class="symbol">&amp;emsp;</span>箱: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">name</span>=<span class="string">&quot;email&quot;</span> <span class="attr">id</span>=<span class="string">&quot;mail&quot;</span></span></span><br><span class="line"><span class="tag">            <span class="attr">placeholder</span>=<span class="string">&quot;请输入您的邮箱...&quot;</span> /&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">fieldset</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;submit&quot;</span> <span class="attr">value</span>=<span class="string">&quot;提交&quot;</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">form</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013171617740.png" alt="image-20211013171617740" style="zoom:50%;border: solid" />    



<h2 id="11-11-文本域"><a href="#11-11-文本域" class="headerlink" title="11,11 文本域"></a>11,11 文本域</h2><p>当用户不满足与仅仅输入一行文字的时候 , 我们需要用到多行文本框</p>
<p>自我介绍 , 编写邮件内容的时候</p>
<ul>
<li><strong>属性 :</strong><ul>
<li>**cols : **每行显示的字符的个数 (不准) , 文本域的宽度</li>
<li>**rows : **显示的行数 , 文本域的高度</li>
<li>**placeholder : ** 提示信息</li>
</ul>
</li>
</ul>
<p><strong>==注意 : 文本域的默认内容 , 不是通过 value 实现的 , 而是讲内容写在开始标签和闭合标签之间的==</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">自我介绍:</span><br><span class="line"><span class="tag">&lt;<span class="name">br</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">textarea</span> <span class="attr">rows</span>=<span class="string">&quot;5&quot;</span> <span class="attr">cols</span>=<span class="string">&quot;10&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;请简单介绍一下你自己...&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">textarea</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211013173016091.png" alt="image-20211013173016091" style="border: solid" />    







<h1 id="12-内联框架"><a href="#12-内联框架" class="headerlink" title="12, 内联框架"></a>12, 内联框架</h1><p>在 HTML 中使用 <strong>iframe</strong> 定义内联框架</p>
<p>作用 : 可以使一个 HTML 文档中 , 通过内联框架嵌入另一个 HTML 文档的内容</p>
<p>效果 : 多网页同屏</p>
<h2 id="12-1-属性"><a href="#12-1-属性" class="headerlink" title="12,1 属性"></a>12,1 属性</h2><ul>
<li><p><strong>width / height :</strong> 设置内联框架的宽度和高度 , 属性值是像素或者百分比</p>
<p>==注意 : 高度没有父级元素的情况下无法设置百分比的 , 因为没有参照 , 浏览器的高度是不固定的无法参照==</p>
</li>
<li><p>**src : **嵌入网页的地址, 框架中显示的最初的页面</p>
</li>
<li><p>**frameborder : **边框</p>
<ul>
<li>1 : 有</li>
<li>0 : 没有</li>
</ul>
</li>
<li><p>**scrolling : **是否有滚动条</p>
<ul>
<li>yes</li>
<li>no</li>
<li>auto 自适应 , 默认的</li>
</ul>
</li>
</ul>
<h2 id="12-2-内联框架的使用"><a href="#12-2-内联框架的使用" class="headerlink" title="12,2 内联框架的使用"></a>12,2 内联框架的使用</h2><blockquote>
<p>代码实例 : 网页的切换</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- </span></span><br><span class="line"><span class="comment">    通过超链接的方式实现,内联框架中页面的切换</span></span><br><span class="line"><span class="comment">    超链接的 target 可以指定超链接中的网页在哪个内联框架中打开</span></span><br><span class="line"><span class="comment">    需要为 iframe 添加对应的name属性</span></span><br><span class="line"><span class="comment">    方式: 将超链接的 target 属性值定义为对应的内联框架的 name 属性值</span></span><br><span class="line"><span class="comment">--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;home.html&quot;</span> <span class="attr">target</span>=<span class="string">&quot;aa&quot;</span>&gt;</span>主页<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;news.html&quot;</span> <span class="attr">target</span>=<span class="string">&quot;aa&quot;</span>&gt;</span>新闻<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;video.html&quot;</span> <span class="attr">target</span>=<span class="string">&quot;aa&quot;</span>&gt;</span>视频<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">br</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">iframe</span> <span class="attr">name</span>=<span class="string">&quot;aa&quot;</span> <span class="attr">src</span>=<span class="string">&quot;home.html&quot;</span> <span class="attr">width</span>=<span class="string">&quot;50%&quot;</span> <span class="attr">height</span>=<span class="string">&quot;400px&quot;</span> <span class="attr">frameborder</span>=<span class="string">&quot;1&quot;</span> </span></span><br><span class="line"><span class="tag"><span class="attr">scrolling</span>=<span class="string">&quot;auto&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">iframe</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211014092111826.png" alt="image-20211014092111826" style="zoom:50%;" />    



<blockquote>
<p>代码实例 : 多网页同屏</p>
</blockquote>
<p><strong>index.html</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 顶部 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">iframe</span> <span class="attr">src</span>=<span class="string">&quot;top.html&quot;</span> <span class="attr">width</span>=<span class="string">&quot;100%&quot;</span> <span class="attr">height</span>=<span class="string">&quot;100px&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">iframe</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 左侧 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">iframe</span> <span class="attr">src</span>=<span class="string">&quot;left.html&quot;</span> <span class="attr">width</span>=<span class="string">&quot;35%&quot;</span> <span class="attr">height</span>=<span class="string">&quot;500px&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">iframe</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 右侧 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">iframe</span> <span class="attr">src</span>=<span class="string">&quot;right.html&quot;</span> <span class="attr">name</span>=<span class="string">&quot;right&quot;</span> <span class="attr">width</span>=<span class="string">&quot;64%&quot;</span> <span class="attr">height</span>=<span class="string">&quot;500px&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">iframe</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>left.html</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">ul</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;home.html&quot;</span> <span class="attr">target</span>=<span class="string">&quot;right&quot;</span>&gt;</span>主页内容<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;news.html&quot;</span> <span class="attr">target</span>=<span class="string">&quot;right&quot;</span>&gt;</span>新闻资讯<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;video.html&quot;</span> <span class="attr">target</span>=<span class="string">&quot;right&quot;</span>&gt;</span>视频播放<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">ul</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>right.html</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>请 点 击 左 侧 链 接 , 跳 转 至 对 应 的 页 面 浏 览 !<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>top.html</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h1</span>&gt;</span>欢 迎 使 用 iframe ! ! ! ! !<span class="tag">&lt;/<span class="name">h1</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211014094617041.png" alt="image-20211014094617041" style="zoom: 33%;border: solid" />    

<p>​    </p>
<h1 id="13-HTML5"><a href="#13-HTML5" class="headerlink" title="13, HTML5"></a>13, HTML5</h1><ul>
<li>新增标签</li>
<li>新增了一些表单的属性</li>
<li>新增了input 不同的功能</li>
</ul>
<h1 id="14-HTML5-新增语义标签"><a href="#14-HTML5-新增语义标签" class="headerlink" title="14, HTML5 新增语义标签"></a>14, HTML5 新增语义标签</h1><p><strong>H5 中这些语义标签的作用 , 和 div 是一样的 , 区别在于名称不同</strong></p>
<p><strong>优势 : 可以直接通过标签名字识别对应网页中某一个区域的内容</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">header</span>&gt;</span>网页的头部信息<span class="tag">&lt;/<span class="name">header</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">nav</span>&gt;</span>网页导航栏信息<span class="tag">&lt;/<span class="name">nav</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">article</span>&gt;</span>网页中的内容标签<span class="tag">&lt;/<span class="name">article</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">section</span>&gt;</span>定义文档的某个区域<span class="tag">&lt;/<span class="name">section</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">aside</span>&gt;</span>定义网页中的侧边栏<span class="tag">&lt;/<span class="name">aside</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">footer</span>&gt;</span>网页的尾部标签<span class="tag">&lt;/<span class="name">footer</span>&gt;</span></span><br></pre></td></tr></table></figure>



<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211014100423497.png" alt="image-20211014100423497" style="zoom:50%;" />    

<ul>
<li>使用注意点<ul>
<li>这种语义化的标签是针对搜索引擎的 , 写在这些标签中的内容更容易被找到</li>
<li>这些标签可以在一个网页中使用多次 (前提 : 合理)</li>
<li>兼容性: 在 IE 9 中需要将他们装换为块级元素</li>
</ul>
</li>
</ul>
<h1 id="15-HTML新增媒体标签"><a href="#15-HTML新增媒体标签" class="headerlink" title="15, HTML新增媒体标签"></a>15, HTML新增媒体标签</h1><ul>
<li>视频 : <strong>video</strong></li>
<li>音频 : <strong>audio</strong></li>
</ul>
<h2 id="15-1-H5视频标签"><a href="#15-1-H5视频标签" class="headerlink" title="15,1 H5视频标签"></a>15,1 H5视频标签</h2><ul>
<li><p>**src : **视频的资源路径</p>
</li>
<li><p>**width / height : **视屏的宽高</p>
</li>
<li><p>**controls : **向用户展示播放组件</p>
</li>
<li><p>**autoplay : **自动播放</p>
<p>谷歌浏览器需要添加静音属性 , 才能够自动播放</p>
</li>
<li><p>**muted : **静音播放</p>
</li>
<li><p>**loop : **循环播放</p>
</li>
<li><p>**poster : **视频加载时的等待的图片 , 属性值就是图片的地址</p>
</li>
</ul>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>视频标签<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">video</span> <span class="attr">width</span>=<span class="string">&quot;800&quot;</span> <span class="attr">height</span>=<span class="string">&quot;600&quot;</span> <span class="attr">src</span>=<span class="string">&quot;video/星海湾大桥.mp4&quot;</span></span></span><br><span class="line"><span class="tag">       <span class="attr">controls</span>=<span class="string">&quot;controls&quot;</span> <span class="attr">autoplay</span>=<span class="string">&quot;autoplay&quot;</span> <span class="attr">muted</span>=<span class="string">&quot;muted&quot;</span></span></span><br><span class="line"><span class="tag">       <span class="attr">loop</span>=<span class="string">&quot;loop&quot;</span> <span class="attr">poster</span>=<span class="string">&quot;img/img03.png&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">video</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211014102344449.png" alt="image-20211014102344449" style="zoom:50%;" />    



<h2 id="15-2-音频标签"><a href="#15-2-音频标签" class="headerlink" title="15,2 音频标签"></a>15,2 音频标签</h2><ul>
<li><p>**src : **音频的资源路径</p>
</li>
<li><p>**controls : **向用户展示播放组件</p>
</li>
<li><p>**autoplay : **自动播放</p>
</li>
<li><p>**muted : **静音播放</p>
</li>
<li><p>**loop : **循环播放</p>
</li>
</ul>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>音频标签<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">audio</span> <span class="attr">src</span>=<span class="string">&quot;audio/0721_1.mp3&quot;</span> <span class="attr">controls</span>=<span class="string">&quot;controls&quot;</span></span></span><br><span class="line"><span class="tag"><span class="attr">autoplay</span>=<span class="string">&quot;autoplay&quot;</span> <span class="attr">muted</span>=<span class="string">&quot;muted&quot;</span> <span class="attr">loop</span>=<span class="string">&quot;loop&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">audio</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211014103223052.png" alt="image-20211014103223052" style="zoom:50%;border: solid" />    





<h1 id="16-H5-新增的表单的类型"><a href="#16-H5-新增的表单的类型" class="headerlink" title="16, H5 新增的表单的类型"></a>16, H5 新增的表单的类型</h1><p><strong>新增 input 标签的 type 属性值</strong></p>
<ul>
<li>email : 邮箱</li>
<li>url : 地址 , 网址</li>
<li>date : 日期</li>
<li>tel : 电话</li>
<li>time : 时间</li>
<li>month : 月份</li>
<li>week : 星期</li>
<li>color : 取色板</li>
</ul>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span>H5新增表单类型<span class="tag">&lt;/<span class="name">h3</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">form</span> <span class="attr">action</span>=<span class="string">&quot;home.html&quot;</span> <span class="attr">method</span>=<span class="string">&quot;get&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">ul</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">            邮箱: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;email&quot;</span> <span class="attr">name</span>=<span class="string">&quot;email&quot;</span> <span class="attr">id</span>=<span class="string">&quot;mail&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;请输入邮箱&quot;</span> /&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">            地址: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;url&quot;</span> <span class="attr">name</span>=<span class="string">&quot;url&quot;</span> <span class="attr">id</span>=<span class="string">&quot;url&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;请输入网址&quot;</span> /&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">            日期: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;date&quot;</span> <span class="attr">name</span>=<span class="string">&quot;date&quot;</span> <span class="attr">id</span>=<span class="string">&quot;date&quot;</span> /&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">            电话: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;tel&quot;</span> <span class="attr">name</span>=<span class="string">&quot;tel&quot;</span> <span class="attr">id</span>=<span class="string">&quot;tel&quot;</span> <span class="attr">placeholder</span>=<span class="string">&quot;请输入电话&quot;</span> /&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">            时间: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;time&quot;</span> <span class="attr">name</span>=<span class="string">&quot;time&quot;</span> <span class="attr">id</span>=<span class="string">&quot;time&quot;</span> /&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">            月份: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;month&quot;</span> <span class="attr">name</span>=<span class="string">&quot;mon&quot;</span> <span class="attr">id</span>=<span class="string">&quot;mon&quot;</span> /&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">            星期: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;week&quot;</span> <span class="attr">name</span>=<span class="string">&quot;week&quot;</span> <span class="attr">id</span>=<span class="string">&quot;week&quot;</span> /&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">li</span>&gt;</span></span><br><span class="line">            颜色: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;color&quot;</span> <span class="attr">name</span>=<span class="string">&quot;color&quot;</span> <span class="attr">id</span>=<span class="string">&quot;color&quot;</span> /&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">li</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">ul</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;submit&quot;</span> <span class="attr">value</span>=<span class="string">&quot;提交&quot;</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">form</span>&gt;</span></span><br></pre></td></tr></table></figure>

<img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211014110328355.png" alt="image-20211014110328355" style="zoom:50%;border: solid" />    



<h1 id="17-HTML5新增表单属性"><a href="#17-HTML5新增表单属性" class="headerlink" title="17, HTML5新增表单属性"></a>17, HTML5新增表单属性</h1><ul>
<li>**required : **当表单提交时, 拥有该属性的空间内容不可为空</li>
<li>**autofocus : **自动聚焦 , 在网页加载完成时将鼠标的光标移动到文本框中</li>
<li>**autocomplete : ** 当用户在文本框中输入内容的时 , 浏览器会根据输入的历史将之前相关的内容显示在输入框下的下拉框中<ul>
<li>on : 开启列表</li>
<li>off : 关闭列表</li>
</ul>
</li>
<li>**multiple : **在文件域中进行多选的操作</li>
<li>**pattern : **属性值为正则表达式 , 用于判断文字的字符格式</li>
</ul>
<blockquote>
<p>代码实例</p>
</blockquote>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">form</span> <span class="attr">action</span>=<span class="string">&quot;home.html&quot;</span> <span class="attr">method</span>=<span class="string">&quot;get&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">        用户名: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">name</span>=<span class="string">&quot;username&quot;</span> <span class="attr">id</span>=<span class="string">&quot;un&quot;</span> <span class="attr">required</span>=<span class="string">&quot;required&quot;</span></span></span><br><span class="line"><span class="tag">                    <span class="attr">autofocus</span>=<span class="string">&quot;autofocus&quot;</span> <span class="attr">autocomplete</span>=<span class="string">&quot;off&quot;</span>/&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">        文件域: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;file&quot;</span> <span class="attr">name</span>=<span class="string">&quot;file&quot;</span> <span class="attr">id</span>=<span class="string">&quot;fil&quot;</span> <span class="attr">multiple</span>=<span class="string">&quot;multiple&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span>&gt;</span></span><br><span class="line">        <span class="comment">&lt;!-- </span></span><br><span class="line"><span class="comment">            11位数字内,以1开头</span></span><br><span class="line"><span class="comment">            \d: 任意数字</span></span><br><span class="line"><span class="comment">            &#123;n&#125;:n位字符</span></span><br><span class="line"><span class="comment">            \d&#123;n&#125;可以在文本框中输入n个数字内容</span></span><br><span class="line"><span class="comment">        --&gt;</span></span><br><span class="line">        电<span class="symbol">&amp;emsp;</span>话: <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;text&quot;</span> <span class="attr">name</span>=<span class="string">&quot;tel&quot;</span> <span class="attr">id</span>=<span class="string">&quot;tel&quot;</span> <span class="attr">pattern</span>=<span class="string">&quot;1\d&#123;10&#125;&quot;</span> /&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">&quot;submit&quot;</span> <span class="attr">value</span>=<span class="string">&quot;提交&quot;</span>/&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">form</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p><img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211014112610051.png" alt="image-20211014112610051" style="zoom:50%;" />    <img src= "https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/loading.gif" data-lazy-src="D:\blog\source\_posts\01-HTML.assets\image-20211014112620739.png" alt="image-20211014112620739" style="zoom:50%;" /></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">lee</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://blog.cai2.wang/2021/11/16/Done/Html5/">http://blog.cai2.wang/2021/11/16/Done/Html5/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://blog.cai2.wang" target="_blank">李世龙</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/html/">html</a></div><div class="post_share"><div class="social-share" data-image="https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/undraw_good_team_m7uu.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button button--animated"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/wechat.jpg" target="_blank"><img class="post-qr-code-img" src="https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/wechat.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/alipay.jpg" target="_blank"><img class="post-qr-code-img" src="https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/alipay.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2021/11/16/Done/es6%E7%AC%94%E8%AE%B0/"><img class="prev-cover" src="https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/undraw_In_progress_re_m1l6.png" onerror="onerror=null;src='https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">es6</div></div></a></div><div class="next-post pull-right"><a href="/2021/11/16/Done/JS%E4%BD%9C%E7%94%A8%E5%9F%9F%E4%B8%8E%E9%97%AD%E5%8C%85/"><img class="next-cover" src="https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/undraw_social_interaction_cy9i.png" onerror="onerror=null;src='https://cdn.jsdelivr.net/gh/Cai2w/cdn/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">JS环境作用域与闭包</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#1-HTML"><span class="toc-number">1.</span> <span class="toc-text">1, HTML</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-1-%E4%BB%80%E4%B9%88%E6%98%AF-HTML"><span class="toc-number">1.1.</span> <span class="toc-text">1,1 什么是 HTML</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#2-%E5%B8%B8%E7%94%A8%E7%9A%84%E6%B5%8F%E8%A7%88%E5%99%A8"><span class="toc-number">2.</span> <span class="toc-text">2, 常用的浏览器</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#3-Web%E6%A0%87%E5%87%86"><span class="toc-number">3.</span> <span class="toc-text">3, Web标准</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#3-1-%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81-Web-%E6%A0%87%E5%87%86"><span class="toc-number">3.1.</span> <span class="toc-text">3,1 为什么需要 Web 标准</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-2-Web-%E6%A0%87%E5%87%86%E7%9A%84%E6%9E%84%E6%88%90"><span class="toc-number">3.2.</span> <span class="toc-text">3,2 Web 标准的构成</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#4-HTML%E6%A0%87%E7%AD%BE"><span class="toc-number">4.</span> <span class="toc-text">4, HTML标签</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#5-HTML%E8%AF%AD%E6%B3%95%E8%A7%84%E8%8C%83"><span class="toc-number">5.</span> <span class="toc-text">5, HTML语法规范</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#5-1-%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95%E8%A7%84%E8%8C%83"><span class="toc-number">5.1.</span> <span class="toc-text">5,1 基本语法规范</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-2-%E6%A0%87%E7%AD%BE%E7%9A%84%E5%85%B3%E7%B3%BB"><span class="toc-number">5.2.</span> <span class="toc-text">5,2 标签的关系</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#6-HTML%E5%9F%BA%E6%9C%AC%E7%BB%93%E6%9E%84"><span class="toc-number">6.</span> <span class="toc-text">6, HTML基本结构</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#7-HTML%E7%9A%84%E5%B8%B8%E7%94%A8%E6%A0%87%E7%AD%BE"><span class="toc-number">7.</span> <span class="toc-text">7, HTML的常用标签</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#7-1-%E6%A0%87%E9%A2%98%E6%A0%87%E7%AD%BE"><span class="toc-number">7.1.</span> <span class="toc-text">7,1 标题标签</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-2-%E6%AE%B5%E8%90%BD%E5%92%8C%E6%8D%A2%E8%A1%8C"><span class="toc-number">7.2.</span> <span class="toc-text">7,2 段落和换行</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-3-%E6%96%87%E6%9C%AC%E6%A0%BC%E5%BC%8F%E5%8C%96%E6%A0%87%E7%AD%BE"><span class="toc-number">7.3.</span> <span class="toc-text">7,3 文本格式化标签</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-4-lt-div-gt-%E5%92%8C-lt-span-gt"><span class="toc-number">7.4.</span> <span class="toc-text">7,4 &lt;div&gt; 和 &lt;span&gt;</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-5-%E5%9B%BE%E5%83%8F%E6%A0%87%E7%AD%BE%E5%92%8C%E8%B7%AF%E5%BE%84"><span class="toc-number">7.5.</span> <span class="toc-text">7,5 图像标签和路径</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-6-%E8%B6%85%E9%93%BE%E6%8E%A5%E6%A0%87%E7%AD%BE"><span class="toc-number">7.6.</span> <span class="toc-text">7,6 超链接标签</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#8-%E7%89%B9%E6%AE%8A%E5%AD%97%E7%AC%A6"><span class="toc-number">8.</span> <span class="toc-text">8, 特殊字符</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#9-%E8%A1%A8%E6%A0%BC%E6%A0%87%E7%AD%BE"><span class="toc-number">9.</span> <span class="toc-text">9, 表格标签</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#9-1-%E8%A1%A8%E6%A0%BC%E7%9A%84%E7%BB%93%E6%9E%84"><span class="toc-number">9.1.</span> <span class="toc-text">9,1 表格的结构</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#9-2-%E8%A1%A8%E6%A0%BC%E7%9A%84%E5%B1%9E%E6%80%A7"><span class="toc-number">9.2.</span> <span class="toc-text">9,2 表格的属性</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#9-3-%E8%A1%A8%E6%A0%BC%E7%BB%93%E6%9E%84%E5%8C%96%E6%A0%87%E7%AD%BE"><span class="toc-number">9.3.</span> <span class="toc-text">9,3 表格结构化标签</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#9-4-%E8%A1%A8%E6%A0%BC%E5%90%88%E5%B9%B6%E5%8D%95%E5%85%83%E6%A0%BC"><span class="toc-number">9.4.</span> <span class="toc-text">9,4 表格合并单元格</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#10-%E5%88%97%E8%A1%A8%E6%A0%87%E7%AD%BE"><span class="toc-number">10.</span> <span class="toc-text">10, 列表标签</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#11-%E8%A1%A8%E5%8D%95"><span class="toc-number">11.</span> <span class="toc-text">11, 表单</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#11-1-%E4%BB%80%E4%B9%88%E6%98%AF%E8%A1%A8%E5%8D%95"><span class="toc-number">11.1.</span> <span class="toc-text">11,1 什么是表单</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#11-2-%E8%A1%A8%E5%8D%95%E7%9A%84%E7%BB%84%E6%88%90"><span class="toc-number">11.2.</span> <span class="toc-text">11,2 表单的组成</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#11-3-input%E8%A1%A8%E5%8D%95%E5%85%83%E7%B4%A0"><span class="toc-number">11.3.</span> <span class="toc-text">11,3 input表单元素</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#11-4-label%E6%A0%87%E7%AD%BE"><span class="toc-number">11.4.</span> <span class="toc-text">11,4 label标签</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#11-5-%E4%B8%8B%E6%8B%89%E5%88%97%E8%A1%A8"><span class="toc-number">11.5.</span> <span class="toc-text">11,5 下拉列表</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#11-6-%E8%A1%A8%E5%8D%95%E5%9F%9F"><span class="toc-number">11.6.</span> <span class="toc-text">11,6 表单域</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#11-7-%E8%A1%A8%E5%8D%95%E6%8F%90%E4%BA%A4%E7%9A%84%E6%96%B9%E5%BC%8F"><span class="toc-number">11.7.</span> <span class="toc-text">11,7 表单提交的方式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#11-8-button%E6%A0%87%E7%AD%BE"><span class="toc-number">11.8.</span> <span class="toc-text">11,8 button标签</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#11-9-%E8%A1%A8%E5%8D%95%E7%9A%84%E7%BB%93%E6%9E%84%E6%A0%87%E7%AD%BE"><span class="toc-number">11.9.</span> <span class="toc-text">11,9 表单的结构标签</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#11-11-%E6%96%87%E6%9C%AC%E5%9F%9F"><span class="toc-number">11.10.</span> <span class="toc-text">11,11 文本域</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#12-%E5%86%85%E8%81%94%E6%A1%86%E6%9E%B6"><span class="toc-number">12.</span> <span class="toc-text">12, 内联框架</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#12-1-%E5%B1%9E%E6%80%A7"><span class="toc-number">12.1.</span> <span class="toc-text">12,1 属性</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#12-2-%E5%86%85%E8%81%94%E6%A1%86%E6%9E%B6%E7%9A%84%E4%BD%BF%E7%94%A8"><span class="toc-number">12.2.</span> <span class="toc-text">12,2 内联框架的使用</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#13-HTML5"><span class="toc-number">13.</span> <span class="toc-text">13, HTML5</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#14-HTML5-%E6%96%B0%E5%A2%9E%E8%AF%AD%E4%B9%89%E6%A0%87%E7%AD%BE"><span class="toc-number">14.</span> <span class="toc-text">14, HTML5 新增语义标签</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#15-HTML%E6%96%B0%E5%A2%9E%E5%AA%92%E4%BD%93%E6%A0%87%E7%AD%BE"><span class="toc-number">15.</span> <span class="toc-text">15, HTML新增媒体标签</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#15-1-H5%E8%A7%86%E9%A2%91%E6%A0%87%E7%AD%BE"><span class="toc-number">15.1.</span> <span class="toc-text">15,1 H5视频标签</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#15-2-%E9%9F%B3%E9%A2%91%E6%A0%87%E7%AD%BE"><span class="toc-number">15.2.</span> <span class="toc-text">15,2 音频标签</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#16-H5-%E6%96%B0%E5%A2%9E%E7%9A%84%E8%A1%A8%E5%8D%95%E7%9A%84%E7%B1%BB%E5%9E%8B"><span class="toc-number">16.</span> <span class="toc-text">16, H5 新增的表单的类型</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#17-HTML5%E6%96%B0%E5%A2%9E%E8%A1%A8%E5%8D%95%E5%B1%9E%E6%80%A7"><span class="toc-number">17.</span> <span class="toc-text">17, HTML5新增表单属性</span></a></li></ol></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2021 - 2022 By lee</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">这是footer</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (true){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><script src="/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>if (document.getElementsByClassName('mermaid').length) {
  if (window.mermaidJsLoad) mermaid.init()
  else {
    getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(() => {
      window.mermaidJsLoad = true
      mermaid.initialize({
        theme: 'default',
      })
      true && mermaid.init()
    })
  }
}</script></div><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = false;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="false"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = [
  'title',
  '#config-diff',
  '#body-wrap',
  '#rightside-config-hide',
  '#rightside-config-show',
  '.js-pjax'
]

if (false) {
  pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
}

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.removeEventListener('scroll', window.tocScrollFn)
  window.removeEventListener('scroll', scrollCollect)

  typeof preloader === 'object' && preloader.initLoading()
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // Analytics
  if (false) {
    MtaH5.pgv()
  }

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>